package com.nf.health.app.widget;

import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.VolleyError;
import com.nf.health.app.R;
import com.nf.health.app.core.HttpActionHandle;
import com.nf.health.app.http.Act;
import com.nf.health.app.http.RequestProvider;
import com.nf.health.app.utils.ClipboardUtils;
import com.nf.health.app.utils.ScreentUtils;

import org.json.JSONException;
import org.json.JSONObject;


/**
 * Created by changpeng on 2016/10/8.
 * 送心意Dialog
 */
public class CopyDialog extends Dialog {

    String discountCode;
    public CopyDialog(Context context, String discountCode) {
        //设置style
        super(context, R.style.dialog3);
        this.discountCode = discountCode;
        init();
    }


    //设置布局
    private void init() {
        setContentView(R.layout.dialog_copy);
        TextView textView = (TextView) findViewById(R.id.tv_copy);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(!TextUtils.isEmpty(discountCode)){
                    ClipboardUtils.copyToClipboard(getContext(),discountCode);
                    Toast.makeText(getContext(),"优惠码已复制到剪切板",Toast.LENGTH_LONG).show();
                    dismiss();
                }
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    }

}
